<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <%@include file="/WEB-INF/jsp/common.jsp"%>
</head>
<body>
<h2>病例档案</h2>
<hr>
<form action="" class="layui-form">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">患者姓名：</label>
            <div class="layui-input-inline">
                <input type="text" id="memberId" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <button type="button" class="layui-btn layui-btn-sm" onclick="reloadData();"><i class="layui-icon layui-icon-search"></i> 搜索</button>
        </div>
    </div>
</form>
<table id="caseTable" lay-filter="caseTable"></table>
<script>
    function reloadData(){
        layui.table.reload("caseTable",{
            page:{
                curr : 1
            },
            where : {
                reserveName : $("#memberId").val(),
            }
        })
    }


    layui.use(['table','form'],function () {
        var table= layui.table;
        var form = layui.form;

        //渲染表格
        table.render({
            elem: '#caseTable',
            url: '${path}/case/list',
            page:true,
            even: true,
            toolbar:'#toolbarDemo',
            cols:[[
                {type:'radio'},
                {field:'caseId',title:'标号'},
                {field:'memberCaseNo',title:'病历号',templet:function (d) {
                        return d.memberCaseNo.medicalRecordNo
                    }},
                {field:'memberId',title:'患者姓名',templet:function (d) {
                        return d.memberCaseNo.reserveName
                    }},
                {field:'caseTell',title:'案例告诉'},
                {field:'caseReview',title:'案例分析'},
                {field:'caseTest',title:'治疗师回复'},
                {field:'caseDate',title:'案件审理日期'},
                {field:'caseStatus',title:'案例状态',templet:function (d) {
                        if (d.caseStatus == 1){
                            return "治疗完成"
                        }
                        return "治疗未完成"
                    }},
                {field:'userId',title:'主治医生',templet:function (d) {
                        return d.userId.username
                    }},
                {field:'caseDate',title:'案例日期'},
                {field:'stateData',title:'治疗开始时间'},
                {field:'endData',title:'治疗结束时间'},
                {field:'hello', title:'操作',toolbar:'#barDemo'}
            ]]
        })

        table.on("tool(caseTable)",function (obj) {
            var data = obj.data;
            var e = obj.event;
            if (e == "edit"){

            }else if (e == "del"){
                layer.open({
                    title: "友情提示",
                    content:"你确定删除吗?",
                    btn:['确定','取消'],
                    yes:function () {
                        $.post("${path}/case/batchDelete",{ids:data.caseId},function () {
                            layer.msg("删除成功了");
                            table.reload('caseTable');
                        });
                    }
                })
            }
        })
    })
</script>
<script type="text/html" id="barDemo">
    <shiro:hasPermission name="dangan:upd">
        <a href="javascript:void(0)" lay-event="edit"><i class="layui-icon layui-icon-edit"></i> </a>
    </shiro:hasPermission>
    <shiro:hasPermission name="dangan:del">
        <a href="javascript:void(0)" lay-event="del"><i class="layui-icon layui-icon-delete"></i></a>
    </shiro:hasPermission>
</script>
</body>
</html>
